---
schemaVersion: 2.2.0
metadata: {}
components:
  - name: tooling-container
    attributes:
      gl/inject-editor: true
    container:
      image: quay.io/mloriedo/universal-developer-image:ubi8-dw-demo
      command:
        - /projects/.gl-editor/start_server.sh
      volumeMounts:
        - name: gl-workspace-data
          path: /projects
      env:
        - name: EDITOR_VOLUME_DIR
          value: "/projects/.gl-editor"
        - name: EDITOR_PORT
          value: "60001"
      endpoints:
        - name: editor-server
          targetPort: 60001
          exposure: public
          secure: true
          protocol: https
      dedicatedPod: false
      mountSources: true
  - name: gl-workspace-data
    volume:
      size: 15Gi
  - name: gl-editor-injector
    container:
      image: registry.gitlab.com/gitlab-org/gitlab-web-ide-vscode-fork/web-ide-injector:1
      volumeMounts:
        - name: gl-workspace-data
          path: /projects
      env:
        - name: EDITOR_VOLUME_DIR
          value: "/projects/.gl-editor"
        - name: EDITOR_PORT
          value: "60001"
      memoryLimit: 128Mi
      memoryRequest: 32Mi
      cpuLimit: 500m
      cpuRequest: 30m
  - name: gl-cloner-injector
    container:
      image: alpine/git:2.36.3
      volumeMounts:
        - name: gl-workspace-data
          path: "/projects"
      args:
        - |-
          if [ ! -d '/projects/test-project' ];
          then
            git clone --branch master http://localhost/test-group/test-project.git /projects/test-project;
            cd /projects/test-project;
            git config user.name "${GIT_AUTHOR_NAME}";
            git config user.email "${GIT_AUTHOR_EMAIL}";
          fi
      command:
        - "/bin/sh"
        - "-c"
      memoryLimit: 128Mi
      memoryRequest: 32Mi
      cpuLimit: 500m
      cpuRequest: 30m
events:
  preStart:
    - gl-editor-injector-command
    - gl-cloner-injector-command
commands:
  - id: gl-editor-injector-command
    apply:
      component: gl-editor-injector
  - id: gl-cloner-injector-command
    apply:
      component: gl-cloner-injector
